#@adminLayout()
#define main()
  <main class="app-content">
    <div class="app-title">
      <div>
        <h1><i class="fa fa-th-list"></i>修改文章</h1>
        <p>网站文章修改</p>
      </div>
      <ul class="app-breadcrumb breadcrumb">
        <li class="breadcrumb-item"><a href="/admin"><i class="fa fa-home fa-lg"></i>仪表盘</a></li>
        <li class="breadcrumb-item active"><a href="/admin/article">文章管理</a></li>
        <li class="breadcrumb-item active"><a href="javascript:;">文章修改</a></li>
      </ul>
    </div>
    
	<form id="myArticleForm" method="post" action="/admin/article/articleUpdate">
	<div class="row">
		<div class="col-md-8">
			<div class="tile">
				<h3 class="tile-title">修改文章</h3>
				<div class="tile-body">
					<input type="hidden" name="article.aid" value="#(article.aid)" />
					<div class="form-group">
						<label class="control-label">文章标题</label>
						<input class="form-control" type="text" name="article.title" value="#(article.title)">
					</div>
					<div class="form-group">
						<label class="control-label">文章内容</label>
						<textarea id="editor1" name="article.content">#escape(article.content ??)</textarea>
					</div>
				</div>
			</div>
		</div>
		<div class="col-md-4">
			<div class="tile">
				<h3 class="tile-title">文章选项</h3>
				<div class="tile-body">
					<div class="form-group">
						<label>文章分类</label>
						<select class="form-control" name="article.type_id" id="article.type_id">
							#for(comments : commentsList) #if(comments.tid == article.type_id)
								<option value="#(comments.tid)" selected>#(comments.name)</option>
							#else
								<option value="#(comments.tid)">#(comments.name)</option>
							#end #end
						</select>
					</div>
					<div class="form-group">
						<label class="control-label">是否热门</label>
						<div class="form-check">
							<label class="form-check-label">
								<input class="form-check-input" type="radio" name="article.is_hot" value="1">热门
							</label>
						</div>
						<div class="form-check">
							<label class="form-check-label">
								<input class="form-check-input" type="radio" name="article.is_hot" value="0" checked="checked">不热门
							</label>
						</div>
					</div>
					<div class="form-group">
						<label class="control-label">分享链接</label>
						<input class="form-control" type="text" name="article.download" value="#(article.download)">
					</div>
					<div class="form-group">
						<label class="control-label">分享密码</label>
						<input class="form-control" type="text" name="article.password" value="#(article.password)">
					</div>
					<div class="form-group">
						<label class="control-label">文章审核</label>
						<div class="form-check">
							<label class="form-check-label">
								<input class="form-check-input" type="radio" name="article.status" value="1" checked="checked">通过
							</label>
						</div>
						<div class="form-check">
							<label class="form-check-label">
								<input class="form-check-input" type="radio" name="article.status" value="2">不通过
							</label>
						</div>
					</div>
					<div class="form-group">
						<label class="control-label">通过/不通过理由</label>
						<input class="form-control" type="text" name="article.reason" value="#(article.reason)">
					</div>
					<div class="form-group">
						<label class="control-label">文章浏览量</label>
						<input class="form-control" type="text" name="article.views" value="#(article.views)"required="required">
					</div>
				</div>
				<div class="tile-footer">
					<input class="btn btn-primary" type="submit" value="确认&nbsp;发起" />
				</div>
			</div>
		</div>
	</div>
	</form>
  </main>
  
#end
#define js()
<script type="text/javascript" src="/static/lib/jquery_form/jquery.form.min.js"></script>
<script type="text/javascript" src="/static/lib/ckeditor/ckeditor.js"></script>

<script>
	$(function() {
		// 初始化 ckeditor
		CKEDITOR.replace('editor1', {height: '350px'});
		// 设置第一个 input 为输入焦点
		$("input:first").focus();
		// 使用 jquery form 插件，接管表单提交事件，并将表单提交自动转化成 ajax 提交
		$("#myArticleForm").ajaxForm({
			dataType: 'json', type: 'POST',
			beforeSerialize: function($form, options) {
				// 将 ckeditor 中的数据同步到 textarea，否则数据无法提交到服务端
				for (instance in CKEDITOR.instances) {
					CKEDITOR.instances[instance].updateElement();
				}
				kit.loading({msg: '正在保存, 请稍候 .....'});
			},
			success: function(ret) {
				kit.closeLoading();
				kit.msg(ret);
				if (ret.state == "ok") {
					kit.go('/admin/article');
				}
			}
		});

	});
</script>
#end